package jm.nj.day10.demo03;

import java.io.*;

/*
 * 字符缓存流:优点效率更高
 *
 * BufferedWriter:写入
 *
 * 使用步骤:
 * 1.创建对象
 * 2.写入
 * 3.刷新
 * 4.关闭
 *
 * BufferedWriter:读取
 * 使用步骤
 * 1.创建对象
 * 2.读取
 * 3关闭
* */
public class Test01 {
    public static void main(String[] args) throws IOException {
        //hello写入aa.txt
        BufferedWriter bw = new BufferedWriter(new FileWriter("aa.txt"));
        //写入
        bw.write("hello");
        //刷新
        bw.flush();
        //关闭
        bw.close();


        //读取
        BufferedReader br = new BufferedReader(new FileReader("aa.txt"));
        int read;
        while((read = br.read()) != -1){
            System.out.print((char)read);
        }
    }

}
